<template>
  <div>
    <div>
      <yd-slider autoplay="3000">
        <yd-slider-item>
            <a href="http://www.ydcss.com">
                <img src="http://static.ydcss.com/uploads/ydui/1.jpg">
            </a>
        </yd-slider-item>
        <yd-slider-item>
            <a href="http://www.ydcss.com">
                <img src="http://static.ydcss.com/uploads/ydui/2.jpg">
            </a>
        </yd-slider-item>
        <yd-slider-item>
            <a href="http://www.ydcss.com">
                <img src="http://static.ydcss.com/uploads/ydui/3.jpg">
            </a>
        </yd-slider-item>
      </yd-slider>
    <div>
    <div class="tj-div">
      <span>推荐理由</span>
    </div>
    <div class="jj-div">
      <span>{{name_info}}</span>
    </div>
    <div class="user">
      <div>
        <img src="http://static.ydcss.com/uploads/ydui/1.jpg" class="tximg">
      </div>
      <div style="float: right;">
        <div class="dr-div">
          <span>达人收藏</span>
        </div>
        <div class="dr-div">
          <span>编者: 吴亦凡</span>
        </div>
      </div>
    </div>
    <div class="line-div"></div>
    <div class="tj-div"><span>住处推荐</span></div>
    </div>
      <yd-infinitescroll :callback='load' ref='infinitescrollDemo'>
        <div v-for="item in list" :key="item.index" slot="list">
          <router-link :to="{path:'liveinfo',query: item}">
            <div class="line-style">
              <div class="listimage">
                <img :src="item.image" alt="" srcset="" class="tj-img">
                <div class="keyuding" v-if="item.book == '0'">可预订</div>
              </div>
              <div style="height:2rem;">
                <div class="xbtdiv"><span>{{item.name}}</span></div>
                <div class="adddiv"><span>距您位置 1.7KM</span></div>
                <div class="xfdiv"><span>人均消费: 50元</span></div>
                <div class="adddiv">平均分: <span>{{item.score}}</span>&nbsp;&nbsp;评论数: <span>{{item.num}}</span></div>
              </div>
              <div class="cgjsdiv" v-html="item.content">
              </div>
            </div>
          </router-link>
        </div>
        <!-- 数据全部加载完毕显示 -->
        <span slot='doneTip'>啦啦啦，啦啦啦，没有数据啦~~</span>
        <!-- 加载中提示，不指定，将显示默认加载中图标 -->
        <img slot='loadingTip' src='http://static.ydcss.com/uploads/ydui/loading/loading10.svg'/>
      </yd-infinitescroll>
    </div>
  </div>
</template>

<script type='text/babel'>
export default {
  data() {
    return {
      pageNo: 1,
      pageSize: 4,
      list: [],
      outdata: [],
      name_info: ''
    }
  },
  mounted: function() {
    this.load();
  },
  methods: {
    load() {
      if (this.$route.query.name_info) {
        this.name_info = this.$route.query.name_info;
      }
      this.searchtext = this.$route.query.searchtext;
      if (this.searchtext !== undefined) {
        this.hdAjax({
          url: this.API.findPlaceNameList,
          method: 'POST',
          data: {
            type: 'H',
            name: this.searchtext,
            pageNo: this.pageNo,
            pageSize: this.pageSize
          },
          success: (resultData) => {
            const _list = resultData.data.results;
            this.list = [...this.list, ..._list];
            if (_list.length < this.pageSize) {
              /* 所有数据加载完毕 */
              this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
              return;
            }
            /* 单次请求数据完毕 */
            this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');
            this.pageNo++;
          }
        });
      } else {
        if (this.$route.query.start_date) {
          this.hdAjax({
            url: this.API.findSelectedList,
            data: {
              start_date: this.$route.query.start_date,
              end_date: this.$route.query.end_date,
              pageNo: this.pageNo,
              pageSize: this.pageSize
            },
            success: (resultData) => {
              console.log('进到我李某的地盘了');
              const _list = resultData.data.results;
              this.list = [...this.list, ..._list];
              if (_list.length < this.pageSize) {
                /* 所有数据加载完毕 */
                this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
                return;
              }
              /* 单次请求数据完毕 */
              this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');
              this.pageNo++;
              // this.indata = this.outdata.sublist;
            }
          });
        } else {
          this.hdAjax({
            url: this.API.findTwoByUseList,
            data: {
              type: 'H',
              id: this.$route.query.id,
              pageNo: this.pageNo,
              pageSize: this.pageSize
            },
            success: (resultData) => {
              const _list = resultData.data.results;
              this.list = [...this.list, ..._list];
              if (_list.length < this.pageSize) {
                /* 所有数据加载完毕 */
                this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.loadedDone');
                return;
              }
              /* 单次请求数据完毕 */
              this.$refs.infinitescrollDemo.$emit('ydui.infinitescroll.finishLoad');
              this.pageNo++;
              // this.indata = this.outdata.sublist;
            }
          });
        }
      }
    }
  }
}
</script>
<style scoped>
.tj-div{
  font-size: 0.4rem;
  padding: 10px 20px 10px 20px;
}
.jj-div{
  font-size: 0.3rem;
  margin-left: 20px;
  margin-right: 20px;
  margin-bottom:10px;
  width:90%;
}
.tximg{
  height: 1rem;
  width: 1.5rem;
  float: right;
  margin-right: 10px;
  border-radius: 30px;
  margin-bottom: 10px;
}
.dr-div{
  font-size: 0.3rem;
  margin: 5px 10px 5px 10px;
  
}
.line-style{
  border-bottom: 1px solid #999999;
  margin-left: 4%;
  width: 92%;
}
.line-div{
  margin-left: 4%;
  width: 92%;
}
.tj-img{
  height: 2rem;
  width: 2.5rem;
  float: left;
  position: relative;
}
.xbtdiv{
  margin-left: 44%;
  font-size: 0.4rem;
  margin-top:30px;
}
.adddiv{
  margin-left: 44%;
  font-size: 0.25rem;
  margin-top:10px;
  
}
.xfdiv{
  margin-left: 44%;
  font-size: 0.3rem;
  margin-top: 10px;
}
.cgjsdiv{
  font-size: 0.3rem;
  margin: 30px 20px 20px 10px;
}
.mapbut{
  border: 1px solid #000;
  border-radius: 20px;
  background: #fff;
  text-align: center;
  position: fixed;
  width: 25%;
  height: 35px;
  line-height: 35px;
  left: 37.5%;
  bottom: 10px;
  z-index: 100;
}
.mapbut .icon-ucenter-outline:before {
  content: "\E616";
  color: #000;
}
.user{
  float: right;
  width: 92%;
  margin-bottom: 10px;
  border-bottom: 1px solid #999999;
  margin-right: 4%;
}
.keyuding {
  padding: 2px 2px 2px 2px;
  position: absolute;
  top: 0;
  width: 40px;
  height: 18px;
  /* right: 0; */
  background-color: #FFA500;
  color: white;
  font-size: 5px
}
.listimage {
  position: relative;
}
</style>
